

%% calibrate model prior
run('Matlab/model_prior/prior.m')


%% estimate "true" DGP
run('Matlab/true_DGP/true_DGP.m')


%% main results
% learning model with no covariates (baseline specification)
K=0; %#ok<*NASGU>
run('Matlab/main_results/posterior_mode.m')
run('Matlab/main_results/print_results.m')
run('Matlab/main_results/results_baseline.m')
run('Matlab/main_results/figures_1_A2.m')
run('Matlab/counterfactuals/great_depression.m')
run('Matlab/counterfactuals/spain_portugal_greece.m')
run('Matlab/counterfactuals/china.m')
run('Matlab/counterfactuals/dprk.m')
run('Matlab/bootstrap/bootstrap.m')
% no-learning model with no covariates
K=0;
run('Matlab/main_results/posterior_mode_NOlearning.m')
run('Matlab/main_results/print_results_NOlearning.m')
run('Matlab/main_results/figures_1_A2.m')
% learning model with 1 covariate
K=1;
run('Matlab/main_results/posterior_mode.m')
run('Matlab/main_results/print_results.m')
% no-learning model with 1 covariate
K=1;
run('Matlab/main_results/posterior_mode_NOlearning.m')
run('Matlab/main_results/print_results_NOlearning.m')
% learning model with 2 covariates
K=2;
run('Matlab/main_results/posterior_mode.m')
run('Matlab/main_results/print_results.m')
run('Matlab/main_results/figures_1_A2.m')
% no-learning model with 2 covariates
K=2;
run('Matlab/main_results/posterior_mode_NOlearning.m')
run('Matlab/main_results/print_results_NOlearning.m')
run('Matlab/main_results/figures_1_A2.m')
% learning model with 3 covariates
K=3;
run('Matlab/main_results/posterior_mode.m')
run('Matlab/main_results/print_results.m')
% no-learning model with 3 covariates
K=3;
run('Matlab/main_results/posterior_mode_NOlearning.m')
run('Matlab/main_results/print_results_NOlearning.m')
% learning model with 4 covariates
K=4;
run('Matlab/main_results/posterior_mode.m')
run('Matlab/main_results/print_results.m')
% no-learning model with 4 covariates
K=4;
run('Matlab/main_results/posterior_mode_NOlearning.m')
run('Matlab/main_results/print_results_NOlearning.m')


%% Table A5: direct diffusion
% learning model with smallest neighborhood
diffRadius=2.5;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion.m')
% no-learning model with smallest neighborhood
diffRadius=2.5;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion_NOlearning.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion_NOlearning.m')
% learning model with smaller neighborhood
diffRadius=1;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion.m')
% no-learning model with smaller neighborhood
diffRadius=1;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion_NOlearning.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion_NOlearning.m')
% learning model with medium neighborhood
diffRadius=0.5;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion.m')
% no-learning model with medium neighborhood
diffRadius=0.5;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion_NOlearning.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion_NOlearning.m')
% learning model with larger neighborhood
diffRadius=0.25;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion.m')
% no-learning model with larger neighborhood
diffRadius=0.25;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion_NOlearning.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion_NOlearning.m')
% learning model with largest neighborhood
diffRadius=0.1;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion.m')
% no-learning model with largest neighborhood
diffRadius=0.1;
run('Matlab/appendix/direct_diffusion/posterior_mode_diffusion_NOlearning.m')
run('Matlab/appendix/direct_diffusion/print_results_diffusion_NOlearning.m')


%% Table A6: alternative democracy measure
run('Matlab/appendix/democracy_measure/true_DGP_robustDM.m')
% learning model
run('Matlab/appendix/democracy_measure/posterior_mode_robustDM.m')
run('Matlab/appendix/democracy_measure/print_results_robustDM.m')
% no-learning model
run('Matlab/appendix/democracy_measure/posterior_mode_robustDM_NOlearning.m')
run('Matlab/appendix/democracy_measure/print_results_robustDM_NOlearning.m')


%% Table A6: five-year panel
run('Matlab/appendix/time_horizon/create_5y_panel.m')
run('Matlab/appendix/time_horizon/prior_robustTH.m')
run('Matlab/appendix/time_horizon/true_DGP_robustTH.m')
% learning model
run('Matlab/appendix/time_horizon/posterior_mode_robustTH.m')
run('Matlab/appendix/time_horizon/print_results_robustTH.m')
% no-learning model
run('Matlab/appendix/time_horizon/posterior_mode_robustTH_NOlearning.m')
run('Matlab/appendix/time_horizon/print_results_robustTH_NOlearning.m')


%% Table A7: alternative similarity measures
run('Matlab/appendix/distance_measures/posterior_mode_robustDistM.m')
run('Matlab/appendix/distance_measures/print_results_robustDistM.m')


%% Table A8: leader turnover effects
% learning model
run('Matlab/appendix/leader_turnover/posterior_mode_robustLT.m')
run('Matlab/appendix/leader_turnover/print_results_robustLT.m')
% no-learning model
run('Matlab/appendix/leader_turnover/posterior_mode_robustLT_NOlearning.m')
run('Matlab/appendix/leader_turnover/print_results_robustLT_NOlearning.m')


%% Tables A9 and A10: heterogeneous elite turnover effects
% learning model
run('Matlab/appendix/thetas/posterior_mode_thetas.m')
run('Matlab/appendix/thetas/print_results_thetas.m')
% no-learning model
run('Matlab/appendix/thetas/posterior_mode_thetas_NOlearning.m')
run('Matlab/appendix/thetas/print_results_thetas_NOlearning.m')



